import { Input, Select } from "antd"
import { FC, useState } from "react"

import { SFormItem } from "@/components/common"
import { useLocale } from "@/locales"
import { notAllowSpecialCharacters } from "@/utils/validate"

const { Option } = Select

interface ParentProxyNameInputProps {
	isHideLabel?: boolean
	onChange?: (text: string) => void
}

const VipParentSelectNumber: FC<ParentProxyNameInputProps> = ({ isHideLabel = false, onChange }) => {
	// eslint-disable-next-line @typescript-eslint/no-unused-vars
	const [val, setValue] = useState("parentProxyName")
	const { newFormat } = useLocale()
	const handleSelect = (value: string) => {
		console.log(value)
		if (value == "1") {
			setValue("parentProxyName")
		} else {
			setValue("topProxyName")
		}
	}
	const selectAfter = (
		<Select defaultValue={isHideLabel ? "" : newFormat("common.top_agent")} onChange={handleSelect}>
			<Option value="1">{isHideLabel ? "" : newFormat("common.top_agent")}</Option>
			<Option value="2">所属总代</Option>
		</Select>
	)
	const onNotAllow = (value: string) => {
		// setValue(val)
		console.log(value)
		onChange && onChange(value)
	}

	return (
		<SFormItem name={val}>
			{/* parentProxyName */}
			{/* <Input
				allowClear
				placeholder={newFormat("common.please_enter")}
				onChange={e => notAllowSpecialCharacters(e, onNotAllow)}
			></Input> */}
			<Input
				placeholder={newFormat("common.please_enter")}
				onChange={e => notAllowSpecialCharacters(e, onNotAllow)}
				addonBefore={selectAfter}
			/>
		</SFormItem>
	)
}

export default VipParentSelectNumber
